import {
	Piece
} from "@/src/chess/Piece.js";

// 初始化棋子
function initRedPiece() {

	let piecesRed = [];
	// code 命名规则：第一个r表示红方，b表示黑方
	// ，第二个为棋子的名称，第三表示棋子在棋盘的位置
	piecesRed.push(new Piece("r_che_r", "车", [8, 0]));
	piecesRed.push(new Piece("r_che_l", "车", [0, 0]));

	piecesRed.push(new Piece("r_ma_r", "马", [7, 0]));
	piecesRed.push(new Piece("r_ma_l", "马", [1, 0]));

	piecesRed.push(new Piece("r_xiang_r", "相", [6, 0]));
	piecesRed.push(new Piece("r_xiang_l", "相", [2, 0]));

	piecesRed.push(new Piece("r_shi_r", "士", [5, 0]));
	piecesRed.push(new Piece("r_shi_l", "士", [3, 0]));

	piecesRed.push(new Piece("r_pao_l", "炮", [1, 2]));
	piecesRed.push(new Piece("r_pao_r", "炮", [7, 2]));

	piecesRed.push(new Piece("r_jiang_z", "帅", [4, 0]));

	piecesRed.push(new Piece("r_bing_l1", "兵", [0, 3]));
	piecesRed.push(new Piece("r_bing_l2", "兵", [2, 3]));
	piecesRed.push(new Piece("r_bing_z", "兵", [4, 3]));
	piecesRed.push(new Piece("r_bing_r1", "兵", [6, 3]));
	piecesRed.push(new Piece("r_bing_r2", "兵", [8, 3]));


	return piecesRed;
}

function initBlackPiece() {

	let piecesBlack = [];
	// code 命名规则：第一个r表示红方，b表示黑方
	// ，第二个为棋子的名称，第三表示棋子在棋盘的位置
	piecesBlack.push(new Piece("b_che_r", "车", [0, 9]));
	piecesBlack.push(new Piece("b_che_l", "车", [8, 9]));

	piecesBlack.push(new Piece("b_ma_r", "马", [1, 9]));
	piecesBlack.push(new Piece("b_ma_l", "马", [7, 9]));

	piecesBlack.push(new Piece("b_xiang_r", "象", [2, 9]));
	piecesBlack.push(new Piece("b_xiang_l", "象", [6, 9]));

	piecesBlack.push(new Piece("b_shi_r", "士", [3, 9]));
	piecesBlack.push(new Piece("b_shi_l", "士", [5, 9]));

	piecesBlack.push(new Piece("b_pao_r", "包", [1, 7]));
	piecesBlack.push(new Piece("b_pao_l", "包", [7, 7]));

	piecesBlack.push(new Piece("b_jiang_z", "将", [4, 9]));

	piecesBlack.push(new Piece("b_bing_r1", "卒", [0, 6]));
	piecesBlack.push(new Piece("b_bing_r2", "卒", [2, 6]));
	piecesBlack.push(new Piece("b_bing_z", "卒", [4, 6]));
	piecesBlack.push(new Piece("b_bing_l1", "卒", [6, 6]));
	piecesBlack.push(new Piece("b_bing_l2", "卒", [8, 6]));


	return piecesBlack;
}

export default function init() {

	let piecesRed = initRedPiece();
	//console.info("红棋:", piecesRed);

	let piecesBlack = initBlackPiece();
	//console.info("黑棋:", piecesBlack);

	return {
		red: piecesRed,
		black: piecesBlack
	}
}
